<?php

namespace App\Http\Middleware;

use App\Traits\ResponseFormat;
use Closure;

class FilterRequest
{
    use ResponseFormat;

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (!$request->json()->count()) {
            return $this->error(42200, '请求参数错误，无效的json');
        }

        return $next($request);
    }
}